package com.itheima;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 * @Author：shenkunlin
 * @date： 2021/7/5 11:40
 * @Description：
 ***/
@SpringBootApplication
@EnableDiscoveryClient
//开启OpenFeign并指定OpenFeign接口扫描包
@EnableFeignClients(basePackages = {"com.itheima.feign"})
public class OrderApplication {

    public static void main(String[] args) {
        SpringApplication.run(OrderApplication.class,args);
    }

    /**
     * 创建RestTemplate实例，并交给SpringIOC容器管理
     */
    @LoadBalanced //开启负载均衡机制
    @Bean
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }
}
